# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: nyyu <mail@nyyu.tk>
# Contributor: Malte Rabenseifner <mail@malte-rabenseifner.de>
# Contributor: EnteEnteEnte <ducksource@duckpond.ch>

pkgname=teamspeak3-server
pkgver=3.13.7
pkgrel=1
pkgdesc='TeamSpeak is software for quality voice communication via the Internet (server)'
url='https://www.teamspeak.com/en/'
arch=('loong64' 'x86_64')
license=('custom')
depends=('glibc' 'gcc-libs')
optdepends=(
  'mariadb-connector-c: MariaDB backend'
  'postgresql-libs: PostgreSQL backend'
)
backup=(etc/teamspeak3-server.ini
        etc/tsdns_settings.ini)
install=teamspeak3-server.install
source=(teamspeak3-server.ini
        teamspeak3-server.service
        PERMISSION.eml)
source_i686=(https://files.teamspeak-services.com/releases/server/${pkgver}/teamspeak3-server_linux_x86-${pkgver}.tar.bz2)
source_x86_64=(https://files.teamspeak-services.com/releases/server/${pkgver}/teamspeak3-server_linux_amd64-${pkgver}.tar.bz2)
sha256sums=('a5ec72d7b8b199e37fc2277d68ef470a6a441e1f964c77f46f0c82d4b586ce6d'
            '73c38a5e70caf042a5997ae831e33be7ba83e5c31ccca01c257c929569149acd'
            '98e3331a803ce0ff85500a3908a61fe105d47ea3c31affc2f605d8385315ca5b')
sha256sums_x86_64=('775a5731a9809801e4c8f9066cd9bc562a1b368553139c1249f2a0740d50041e')

if [ "${CARCH}" == "x86_64" ]; then
  _TSARCH='amd64'
elif [ "${CARCH}" == "i686" ]; then
  _TSARCH='x86'
fi

package() {
  install -Dm 644 teamspeak3-server.ini -t "${pkgdir}/etc"
  install -Dm 644 teamspeak3-server_linux_${_TSARCH}/tsdns/tsdns_settings.ini.sample "${pkgdir}/etc/tsdns_settings.ini"
  install -Dm 644 teamspeak3-server.service -t "${pkgdir}/usr/lib/systemd/system"

  install -Dm 755 teamspeak3-server_linux_${_TSARCH}/ts3server -t "${pkgdir}/usr/bin"
  install -Dm 755 teamspeak3-server_linux_${_TSARCH}/tsdns/tsdnsserver -t "${pkgdir}/usr/bin"
  install -Dm 644 teamspeak3-server_linux_${_TSARCH}/*.so -t "${pkgdir}/usr/lib"
  install -Dm 644 teamspeak3-server_linux_${_TSARCH}/LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"

  install -d "${pkgdir}/usr/share/doc/teamspeak3-server" \
    "${pkgdir}/usr/share/teamspeak3-server"

  cp -a teamspeak3-server_linux_${_TSARCH}/doc "${pkgdir}/usr/share/doc/teamspeak3-server"
  cp -a teamspeak3-server_linux_${_TSARCH}/serverquerydocs "${pkgdir}/usr/share/doc/teamspeak3-server"
  cp -a teamspeak3-server_linux_${_TSARCH}/sql "${pkgdir}/usr/share/teamspeak3-server"

  find "${pkgdir}/usr/share/teamspeak3-server" -type d -exec chmod 755 {} \;
  find "${pkgdir}/usr/share/teamspeak3-server" -type f -exec chmod 644 {} \;
  find "${pkgdir}/usr/share/doc/teamspeak3-server" -type d -exec chmod 755 {} \;
  find "${pkgdir}/usr/share/doc/teamspeak3-server" -type f -exec chmod 644 {} \;
}

# vim: ts=2 sw=2 et:
